import { BadRequestException, Injectable } from "@nestjs/common";
import { UserService } from "../user/user.service";

@Injectable()
export class GateAuthService {
  constructor(private userService: UserService) {}

  async signIn(username: string, pass: string): Promise<any> {
    const user = await this.userService.findOne(username, pass);
    if (!user) {
      throw new BadRequestException();
    }
    const { password, ...result } = user;
    // TODO: Generate a JWT and return it here
    // instead of the user object
    return result;
  }
}
